import jsonp from 'common/js/jsonp.js'
import { commonParams } from './config'

// 获取排行榜数据
export function getRankList() {
  const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg'
  /* eslint-disable */
  let randCallbackName = '__jp' + String(Math.random()).slice(2,8)
  let params = Object.assign({}, commonParams, {
    callback: randCallbackName,
    jsonpCallback: randCallbackName,
    g_tk: 5381,
    uin: 0,
    format: 'jsonp',
    notice: 0,
    platform: 'h5',
    needNewCode: 1
  })
  return jsonp(url, params, { name: randCallbackName })
}

// 获取歌单数据
export function getTopMusicList(topid) {
  const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg'
  /* eslint-disable */
  let randCallbackName = '__jp' + String(Math.random()).slice(2,8)
  let params = Object.assign({}, commonParams, {
    callback: randCallbackName,
    jsonpCallback: randCallbackName,
    g_tk: 5381,
    uin: 0,
    format: 'json',
    notice: 0,
    platform: 'h5',
    needNewCode: 1,
    tpl: 3,
    page: 'detail',
    type: 'top',
    topid: topid
  })
  return jsonp(url, params, { name: randCallbackName })
}
